<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>出版社管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
		function btnEdit(prId) {
			// 正常打开
			if(!prId){
                prId = "";
			}
			top.$.jBox.open("iframe:${ctx}/book/publisher/toEdit?prId="+prId, "新增出版社", 400, 200, {
				buttons: {}, loaded: function () {
					$(".jbox-content", top.document).css("overflow-y", "hidden");
				}, closed: function () {
					$("#booksName").val(window.parent.editbooks);
				}
			});
		}

		function deletePublisher(prId) {
			if(confirm("确定要删除出版社信息？")){
				deletePublisherAjax(prId);
			}
		}
		function deletePublisherAjax(prId) {
			$.ajax({
				type: "POST",
				url: "${ctx}/book/publisher/delete",
				data: {id: prId},
				dataType: "json",
				success: function (data) {
					if (data.code == "0001") {
						top.$.jBox.info(data.msg, '提示', {
							closed: function () {
								window.location.href = "${ctx}/book/publisher/list";
							}
						});
						top.$('.jbox-body .jbox-icon').css('top', '55px');

					} else {
						alertx("删除出版社信息失败");
					}
				}
			});
		}

		function btnClear() {
			$("#searchForm").find("input[type='text']").each(function () {
				$(this).val("");
			});
		}
	</script>
</head>
<body>
<form:form id="searchForm" modelAttribute="bkPublisher" action="${ctx}/book/publisher/list" method="post" class="breadcrumb form-search">
	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	<label>出版社：</label>
	<form:input id="prName" path="prName" htmlEscape="false" maxlength="30" class="input-medium"/>&nbsp;
	<label>所在城市：</label>
	<form:input id="prAddress" path="prAddress" htmlEscape="false" maxlength="30" class="input-medium"/>&nbsp;
	<label>出版社拼音：</label>
	<form:input id="prPy" path="prPy" htmlEscape="false" maxlength="10" class="input-medium"/>&nbsp;

	<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>&nbsp;&nbsp;
	<a href="javascript:void(0)" onclick="btnClear()" class="btn">清空条件</a>
	<a href="javascript:void(0)" onclick="btnEdit()" class="btn">新增</a>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<thead>
	<tr>
		<th width="40">序号</th>
		<th>出版社</th>
		<th>所在城市</th>
        <th>出版社拼音</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody>
	<c:forEach items="${page.list}" var="info" varStatus="status">
		<tr>
            <td>${status.count}</td>
            <td>${info.prName}</td>
            <td>${info.prAddress}</td>
            <td>${info.prPy}</td>
            <td>
                <a href="javascript:void(0)" onclick="btnEdit('${info.prId}')">修改</a>
                <shiro:hasPermission name="book:books:delete">
                    <a href="javascript:void(0);" onclick="deletePublisher('${info.prId}')">删除</a>
                </shiro:hasPermission>
            </td>
		</tr>
	</c:forEach>
	</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>